-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdctl: add initial check perf command #7591
Conversation
My poor laptop failed large load test
|
Is this for #6991? |
@gyuho yes. |
// NewValidatePerfCommand returns the cobra command for "validate-perf". | ||
func NewValidatePerfCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "validate-perf [options]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check-perf
? check perf
? perf check
? perf
? must be a better name..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf seems ok. @gyuho @fanminshi any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check-perf
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's going to be check-perf
, then check perf
might be better. There's probably a few aspects of the cluster worth checking aside from only performance (e.g., check if running latest version, check if hashes match, ...) so check
could cover all those as subcommands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check perf
sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. will change.
|
||
for limit.Wait(ctx) == nil { | ||
binary.PutVarint(k, int64(rand.Intn(math.MaxInt64))) | ||
requests <- v3.OpPut(string(k), v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a cluster and it looks like it's performing slow. So I run validate-perf
to check if it's OK and now the cluster is full of garbage.
Force the command to take a prefix, check if the prefix is empty, and if so, put into the prefix and delete the whole thing on completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. My initial thought is that this tool should be used pre installation. But we can make it better with very little effort.
if ok { | ||
fmt.Println("PASS") | ||
} else { | ||
fmt.Println("FAIL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit(1)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
f82ff26
to
27aefe9
Compare
@heyitsanthony PTAL. |
|
||
// TODO: support customized configuration | ||
cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The workload to check the performance. Options are: s(small), m(medium), l(large), xl(xLarge).") | ||
cmd.Flags().StringVar(&checkPerfPrefix, "prefix", "/etcdctl-check-perf/", "The key prefix used to check the performance.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prefix for writing the performance check's keys
?
} | ||
|
||
// TODO: support customized configuration | ||
cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The workload to check the performance. Options are: s(small), m(medium), l(large), xl(xLarge).") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance check's workload model. Accepted workloads: s(small), m(medium), l(large), xl(xLarge)
?
func NewCheckCommand() *cobra.Command { | ||
cc := &cobra.Command{ | ||
Use: "check <subcommand>", | ||
Short: "check related commands", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commands for checking properties of the etcd cluster
?
var cfg checkPerfCfg | ||
switch checkPerfLoad { | ||
case "s", "small": | ||
cfg = checkPerfCfgMap["s"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var checkPerfAlias = map[string]string {"s" : "s", "small" : "s", ...}
...
cfg, ok := checkPerfAlias[checkPerfLoad]
if !ok { ExitWithError(...) }
?
r := report.NewReport("%4.4f") | ||
var wg sync.WaitGroup | ||
|
||
for i := range clients { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wg.Add(len(clients))
before loop instead of wg.Add(1)
?
ticker := time.NewTicker(time.Second) | ||
|
||
for i := 0; i < cfg.duration; i++ { | ||
<-ticker.C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just time.Sleep(time.Second)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea. I was going to add some cancelation logic. But I guess it is not needed.
for i := 0; i < cfg.clients; i++ { | ||
clients = append(clients, mustClientFromCmd(cmd)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some kind of check to avoid clobbering prefixes?
resp, _ := clients[0].Range(context.Background(), checkPerfPrefix, v3.WithPrefix(), v3.WithLimit(1))
if len(resp.Kvs) > 0 {
ExitWithError(ExitInvalidInput, fmt.Sprintf("prefix %q has keys. Delete with etcdctl del --prefix %s", checkPerfPrefix, checkPerfPrefix)
}
Codecov Report
@@ Coverage Diff @@
## master #7591 +/- ##
==========================================
- Coverage 73.95% 73.56% -0.39%
==========================================
Files 325 326 +1
Lines 26454 26552 +98
==========================================
- Hits 19565 19534 -31
- Misses 5441 5558 +117
- Partials 1448 1460 +12
Continue to review full report at Codecov.
|
2ab354d
to
62e9390
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nits, lgtm otherwise
etcdctl/ctlv3/command/check.go
Outdated
ExitWithError(ExitError, err) | ||
} | ||
if len(resp.Kvs) > 0 { | ||
ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s before check the performance.", checkPerfPrefix, checkPerfPrefix)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ before check the performance./first.?
etcdctl/ctlv3/command/check.go
Outdated
} | ||
|
||
var cfg checkPerfCfg | ||
switch checkPerfAlias[checkPerfLoad] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model, ok := checkPerfAlias[checkPerfLoad]
if !ok {
ExitWithError(ExitBadFeature, fmt.Errorf("unknown load option %v", checkPerfLoad))
}
cfg := checkPerfCfgMap[model]
?
lgtm. Thanks! |
This is a very simple performance validation command. The output is PASS or FAIL. There is nothing much to tune by design. If users want to find out more information, they should use benchmark tool instead.
example output:
I am going to finish up docs if this direction looks good. /cc @heyitsanthony @gyuho